package com.tmxk.day01.lifeng.demo4;
/**
 * 公共的父类
 * @author 19256
 *
 */
public abstract class Pet {
	//被final修饰的成员变量叫常量,常量在使用前未赋值,系统不再提供默认值,需主动赋值,且不能进行二次赋值;
	private String name;
	private int age;
	private String strain;
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public int getAge() {
		return age;
	}
	public void setAge(int age) {
		if(age < 0) {
			this.age = 1;
			System.out.println("宠物年龄不能低于0,系统默认为一岁");
		}else {
			this.age = age;
		}
	}
	public String getStrain() {
		return strain;
	}
	public void setStrain(String strain) {
		this.strain = strain;
	}
	public Pet() {
	}
	public Pet(String name) {
		this.name = name;
	}
	public Pet(String name, int age, String strain) {
		this.name = name;
		this.age = age;
		this.strain = strain;
	}
	public void shout() {
		System.out.println(this.name + "在叫");
	}
	public void showInfo() {
		System.out.print("宠物的基本信息:昵称是:" + this.name + ",年龄是:" +this.age + ",种类是:" + this.strain);
	}
}
